package com.vote.www.service;

import java.util.List;
import java.util.Map;
import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.vote.www.core.page.Pagination;
import com.vote.www.domain.Czjbackground;
import com.vote.www.persistence.CzjbackgroundMapper;
import com.vote.www.utils.UUIDUtils;


@Service("CzjbackgroundService")
public class CzjbackgroundService {
	@Autowired
	private CzjbackgroundMapper czjbackgroundMapper;

	/**
	 * 查询某个czj_background  背景
	 * @param param
	 * @return
	 */
	public Czjbackground getCzjbackground(Map<String,Object> param) {
		return czjbackgroundMapper.getCzjbackground(param);
	}
	
	/**
	 * 查询某个czj_background  背景
	 * @param param
	 * @return
	 */
	public List<String> getCzjbackgroundALL() {
		return czjbackgroundMapper.getCzjbackgroundALL();
	}	
   
	/**
	 * 查询某个czj_background  背景queryImgOrder
	 * @param param
	 * @return
	 */
	public Czjbackground queryImgOrder(Map<String,Object> param) {
		return czjbackgroundMapper.queryImgOrder(param);
	}	
	
	/**
	 * 查询czj_background  背景列表
	 * @return
	 */
	public Map<String,Object> getCzjbackgroundList(Map<String,Object> param) {
		Map<String,Object> returnMap = new HashMap<String,Object>();
		returnMap.put("totalCounts", czjbackgroundMapper.getTotalRows(param));
		returnMap.put("list", czjbackgroundMapper.getCzjbackgroundList(param));
		return returnMap;
	}
   
	
	/**
	 * 查询czj_background  背景列表
	 * @return
	 */
	public  List<Czjbackground> getCzjbackgroundListALL(Map<String,Object> param) {
		List<Czjbackground> list=	czjbackgroundMapper.getCzjbackgroundListALL(param);
		return list;
		
	}	
	
	
	
	/**
	 * 查询czj_background  背景列表
	 * @return
	 */
	public  Pagination getCzjbackgroundList(Map<String,Object> param,int pageSize,Integer pageNo,String order,String sort) {
		Pagination p = new Pagination();
		p.setPageNo(pageNo);
		p.setPageSize(pageSize);
		p.setOrder(order);
		p.setSort(sort);
		param.putAll(p.toMap());
		int count=czjbackgroundMapper.getTotalRows(param);
		List<Czjbackground> list=	czjbackgroundMapper.getCzjbackgroundList(param);
	
		p.setList(list);
		p.setTotalCount(count);
		return p;
		
	}
      
	/**
	 * 新增czj_background  背景
	 * @param czjbackground
	 * @param param
	 */
	@Transactional
	public void insertCzjbackground(Czjbackground czjbackground) {	
		czjbackground.setBackgroundId(UUIDUtils.getUUID());
		czjbackgroundMapper.insertCzjbackground(czjbackground);
	}
   
	/**
	 * 编辑czj_background  背景
	 * @param czjbackground
	 * @param param
	 */
	@Transactional
	public void updateCzjbackground(Czjbackground czjbackground) {
		czjbackgroundMapper.updateCzjbackground(czjbackground);
	}
   
	/**
	 * 删除czj_background  背景
	 * @param param
	 */    
	@Transactional
	public void deleteCzjbackground(List<String> backgroundIdList) {
		for(String backgroundId: backgroundIdList){
	  		Map<String,Object> param = new HashMap<String,Object>();
	  		param.put("backgroundId", backgroundId);
	 	   czjbackgroundMapper.deleteCzjbackground(param);	  		
		}
	}


}